package com.ncwu.application.service.impl;

import com.ncwu.application.service.UserService;

import com.ncwu.domain.entity.User;
import com.ncwu.domain.service.UserDomainService;

import com.ncwu.infrastructure.util.RedisUtil;
import com.ncwu.interfaces.dto.response.UserDetailsDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.awt.image.BufferedImage;
import java.util.List;


/**
 * @author : wuwensheng
 * @date : 13:29 2020/7/1
 */
@Service
@Slf4j
@Order(0)
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDomainService userDomainService;

    @Autowired
    private RedisUtil redisUtil;

    @Override
    public String passWordLogin(String userId, String passWord) {
        return userDomainService.passwordLogin(userId, passWord);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void register(String userId, String userName, String password, String remark) {
        //现在开始用户注册
        userDomainService.register(userId, userName, password, remark);
    }

    @Override
    public Integer sendVerificationCode(String userId) {
        return userDomainService.sendVerificationCode(userId);
    }

    @Override
    public String verificationCodeLogin(String userId, String code) {
        return userDomainService.verificationCodeLogin(userId, code);
    }

    @Override
    public List<User> getUser() {
        return userDomainService.getUser();
    }

    @Override
    public BufferedImage getCaptcha(String userId) {
        return userDomainService.getCaptcha(userId);
    }

    @Override
    public UserDetailsDTO pwdAndCaptchaLogin(String userId, String password, String code) {
        return userDomainService.pwdAndCaptchaLogin(userId, password, code);
    }
}
